<template>
	<view class="list-all">
		<view v-for="(item, index) in list"  :key="`list${index}`" @click="joinPath(item, index)">
			<image class="icon" :src="currentIndex === index ? item.icon_1 : item.icon"></image>
			<view class="text" :class="[currentIndex === index?'active':'']">{{ item.name }}</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"tabBar",
		props: {
			currentIndex: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				list: [
					{
						name: '首页',
						icon: require('../static/img/community/ic_home_n.png'),
						icon_1: require('../static/img/community/ic_home_s.png'),
						url: '/pages/tabbar/tabbar-1/tabbar-1',
						type: 1,
					},
					{
						name: '发帖',
						icon: require('../static/img/community/ic_p.png'),
						icon_1: require('../static/img/community/ic_p_s.png'),
						url: '/pages/user/invitation/setPost',
						type: 2,
					},
					{
						name: '我的',
						icon: require('../static/img/community/ic_mine_n.png'),
						icon_1: require('../static/img/community/ic_mine_s.png'),
						url: '/pages/tabbar/tabbar-5/tabbar-5',
						type: 1,
					}
				]
			};
		},
		methods: {
			joinPath(item, index) {
				if (item.type === 1) {
					uni.switchTab({
						url: item.url
					})
				} else {
					uni.navigateTo({
						url: item.url
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.icon {
		width: 48rpx;
		height: 48rpx;
		margin: 0 auto;
		display: block;
	}
	.list-all {
		display: flex;
		height: 100rpx;
		justify-content: space-between;
		align-items: center;
		font-size: 14px;
		padding: 0 100rpx;
		background-color: #FFFFFF;
		position: fixed;
		bottom: 0;
		left: 0;
		color: #9E9E9E;
		right: 0;
		z-index: 10001;
		border-top: 1px solid #EEEEEE;
	}
	.active {

		color: rgb(33, 210, 255);
	}
</style>
